package action.creditapproval;

import java.io.File;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.apache.struts2.ServletActionContext;

import model.app.AppLoantype;
import model.app.AppRate;
import model.company.Companyfile;
import model.credit.Creditapplyenterprise;
import model.credit.Creditapplypersonal;
import model.creditcheck.Applyopinion;
import model.creditcheck.Applystate;
import model.personal.Personalbasic;

import service.applycheck.AppRateService;
import service.applycheck.ApplyCustomRelationSearchService;
import service.applycheck.ApplyOpinionService;
import service.applycheck.ApplyStateService;
import service.applycheck.ApplyUserService;
import service.credit.AppLoantypeService;
import service.credit.CreditApplyEnterpriseService;
import service.credit.CreditApplyPersonalService;
import service.credit.EnterpriseSearchService;
import service.credit.PersonalSearchService;
import service.custom.CustomServiceDo;
import service.dropdown.DropDownService;
import util.Log;
import util.Time;
import vo.CreditCheckBean;
import vo.EnterpriseInforBean;
import vo.UserBean;
import core.action.BaseAction;
import core.global.Global;
import exception.Exceptions;

public class CreditSurveyActoin extends BaseAction{
	private String state;
	private int type;
	private List<?> creditAcceptBeanList;
	private CreditCheckBean creditCheckBean;
	private List<?> recordList;
	
	private List<Integer> isAccept;
	private List<Integer> acceptPeople;
	
	private AppRate appRate;
	
	private Integer applyid;
	private Integer appid;
	private int isCanChange;
	
	private String advice;
	
	private Double applybaserate;
	private Double slidingscale;
	private Double performrates;
	
	
	private Double loanaccount; // 申请金额
	private Integer applytime; // 申请期限
	private String applytimetype; // 申请期限类型
	
	private ApplyStateService applyStateService;
	private CreditApplyPersonalService creditApplyPersonalService;
	private CreditApplyEnterpriseService creditApplyEnterpriseService;
	private ApplyOpinionService applyOpinionService;
	
	private AppRateService appRateService;
	
	private ApplyUserService applyUserService;
	
	private int upOrDown;
	
	/*贷款类型列表*/
	private List<AppLoantype> loantypeList;
	private AppLoantypeService appLoantypeService;
	
	private List<String> lomList = new ArrayList<String>();
	//private String[] lomList;
	//private String lomList;
	
	private List<?> enssuerList; //保证信息
	private List<?> hypothecateList;//抵押信息
	private List<?> pledgeList; //质押信息
	
	private Creditapplyenterprise creditapplyenterprise;
	private Creditapplypersonal creditApplyPersonal;
	
	private ApplyCustomRelationSearchService applyCustomRelationSearchService;
	
	private EnterpriseInforBean enterpriseInforBean;
	private EnterpriseSearchService enterpriseSearchService;
	
	private Personalbasic person;
	private PersonalSearchService personalSearchService;
	
	private List<?> dcommonList;
	private DropDownService dropDownService;
	
	private List<?> culturaList;
	
	private int searchwhat;
	
	private String searchApplyid;
	
	/**
	 * 保存调查报告文件所需要的service
	 * */
	private CustomServiceDo customServiceDo;
	
	
	
	private String picUrl;//命名规则pic...
	
	private Companyfile cpic200;//命名规则cpic...
	private File pic200;//命名规则pic...
	private String pic200FileName;//命名规则pic...
	
	
	/**
	 * 编辑更改申请信息
	 * */
	public String getOneEdit() throws Exceptions{
		//保证信息列表
		this.enssuerList = this.applyCustomRelationSearchService.getAllEnssuerList(appid);
		//抵押信息列表
		this.hypothecateList = this.applyCustomRelationSearchService.getAllHypothecateList(appid);
		//质押信息列表
		this.pledgeList = this.applyCustomRelationSearchService.getAllPledgeList(appid);
		
		if(type == 1){
			this.culturaList = this.dropDownService.getCommonList(6, 0);
			this.dcommonList = this.dropDownService.getListBean(2, 0);
			creditApplyPersonal = this.creditApplyPersonalService.getOneById(appid);
			this.person = this.personalSearchService.searchOnePerson(creditApplyPersonal.getClientid());
			
			String[] list = creditApplyPersonal.getLoanofmode().replace(" ","").split(",");
			if(list != null){
				this.lomList = Arrays.asList(list);
			}
			this.loantypeList = this.appLoantypeService.getLoanTypeList();
			Log.save("读取", "读取申请号码为：" + appid + "的个人申请信息，进入编辑界面", null);
			return "personal";
		}else if(type == 2){
			creditapplyenterprise = this.creditApplyEnterpriseService.getOneById(appid);
			this.enterpriseInforBean = this.enterpriseSearchService.searchOneEnterprise(creditapplyenterprise.getClientid());
			String[] list = creditapplyenterprise.getLoanofmode().replace(" ","").split(",");
			if(list != null){
				this.lomList = Arrays.asList(list);
			}
			this.loantypeList = this.appLoantypeService.getLoanTypeList();
			//Log.save("读取", "读取申请号码为：" + appid + "的企业申请信息，进入编辑界面", null);
			return "enterprise";
		}else{
			throw new Exceptions("错误");
		}
	}
	
	/**
	 * 默认执行的为显示等待调查的列表信息
	 * */
	public String execute() throws Exceptions{
		if(this.type == 1){
			this.creditAcceptBeanList = this.creditApplyPersonalService.getAllSurveyList("wait");
		}else if(this.type == 2){
			this.creditAcceptBeanList = this.creditApplyEnterpriseService.getAllSurveyList("wait");
		}
		this.searchwhat = 1;
		return "success";
	}
	
	/**
	 * 进入调查信息填写界面
	 * */
	public String applySurvey() throws Exceptions{
		if (this.type == 1) {
			creditCheckBean = this.creditApplyPersonalService.getOneBean(applyid);
			recordList = this.applyOpinionService.getListAllByApplyId(applyid);
			if (this.isCanChange == 1 || this.isCanChange == 2) {
				this.appRate = this.appRateService.getAppRate();
			}
		} else if (this.type == 2) {
			creditCheckBean = this.creditApplyEnterpriseService.getOneBean(applyid);
			recordList = this.applyOpinionService.getListAllByApplyId(applyid);
			if (this.isCanChange == 1 || this.isCanChange == 2) {
				this.appRate = this.appRateService.getAppRate();
			}
		}
		return "detail";
	}
	
	/**
	 * 调查信息的保存提交
	 * */
	public String doSurvey() throws Exception{
		
		if(upOrDown == 1){
			if(this.slidingscale < 0 || this.slidingscale > 300){
				throw new Exceptions("利率设定不合法");
			}
			this.slidingscale = this.slidingscale + 100;
		}else if(upOrDown == 2){
			if(this.slidingscale < 0 || this.slidingscale > 10){
				throw new Exceptions("利率设定不合法");
			}
			this.slidingscale = 100 - this.slidingscale;
		}else{
			throw new Exceptions("利率设定不合法");
		}
		
		if(this.applyStateService.isHaveRecord(appid)){
			this.applyStateService.delAllRecordByApplyid(appid);
			this.applyStateService.resetSurveyAccord(appid);
			if(this.type == 1){
				creditApplyPersonalService.resetApply(appid);
			}else if(this.type == 2){
				creditApplyEnterpriseService.resetApply(appid);
			}
		}
		
		//保存调查文件
		this.fileSave();
		
		UserBean adviceUser = new UserBean();
		UserBean examineUser = new UserBean();
		
		if(this.applyUserService.getUserByRoleId(8) == null && this.applyUserService.getUserByRoleId(6) == null){
			throw new Exceptions("请先设定好相关的人员！");
		}else{
			adviceUser = (UserBean) this.applyUserService.getUserByRoleId(8).get(0);
			examineUser = (UserBean) this.applyUserService.getUserByRoleId(6).get(0);
		}
		
		
		if(this.type == 1){
			Timestamp nowTime = Time.CurrentTimestamp();
			Creditapplypersonal _creditapplypersonal = this.creditApplyPersonalService.getOneById(appid);
			Applystate _applystate = applyStateService.getOneApplyStateByIdAndType(appid, "A");
			
			if(_creditapplypersonal == null || _applystate == null){
				throw new Exception("后台操作信息为空，请检查你申请信息!");
			}
			
			int count = _creditapplypersonal.getCount();
			
			/*设定调查的信息*/
			try{
				_applystate.setChecktime(nowTime);
				_applystate.setCheckopinion(advice);
				_applystate.setCheckstate(1);
				_applystate.setCount(count);
			}catch(Exception e){
				throw new Exceptions("信息更改失败!");
			}
			
			/*保存调查信息*/
			try{
				applyStateService.save(_applystate);
				this.applyOpinionService.save(new Applyopinion(appid, Global.userid().intValue(), null, "调查", advice, null, nowTime, 1, count, cpic200.getPath()));
			}catch(Exception e){
				throw new Exception("调查信息保存信息失败!");
			}
			
			/*检查是否全部的调查人员已经操作完成*/
			if(applyStateService.isAllSurveyDo(appid, "A")){
				applyStateService.saveAllByManagerId(appid, examineUser.getUserId().intValue(), "B", this.type, count);
				applyStateService.saveAllByManagerId(appid, adviceUser.getUserId().intValue(), "BB", this.type, count);
				_creditapplypersonal.setCreditstate(21);
				_creditapplypersonal.setIsdone(1);
			}
			
			/*设置利率，有问题，改进 设定利率及相关修改的信息*/
			
			try {
				//_creditapplypersonal.setApplytime(applytime);
				//_creditapplypersonal.setApplytimetype(applytimetype);
				_creditapplypersonal.setLoanaccount(loanaccount);
				_creditapplypersonal.setApplybaserate(applybaserate);
				_creditapplypersonal.setSlidingscale(slidingscale);
				_creditapplypersonal.setPerformrates(performrates);
			} catch (Exception e) {
				throw new Exceptions("利率设定失败，请检查你的利率是否合法!");
			}
			
			try {
				this.creditApplyPersonalService.save(_creditapplypersonal);
				Log.save("插入", "个人调查信息的保存，申请单的号码为：" + _creditapplypersonal.getApplyid(), "调查报告的路径为：" + cpic200.getPath());
			} catch (Exception e) {
				throw new Exceptions("在执行过程中出现了错误了!");
			}
		}else if(this.type == 2){
			Timestamp nowTime = Time.CurrentTimestamp();
			Creditapplyenterprise _creditApplyEnterprise = this.creditApplyEnterpriseService.getOneById(appid);
			Applystate _applystate = applyStateService.getOneApplyStateByIdAndType(appid, "A");
			if(_creditApplyEnterprise == null || _applystate == null){
				throw new Exception("后台操作信息为空，请检查你申请信息!");
			}
			int count = _creditApplyEnterprise.getCount();
			
			try {
				_applystate.setChecktime(nowTime);
				_applystate.setCheckopinion(advice);
				_applystate.setCheckstate(1);
				_applystate.setCount(count);
			} catch (Exception e) {
				throw new Exceptions("信息更改失败!");
			}
			
			try {
				applyStateService.save(_applystate);
				this.applyOpinionService.save(new Applyopinion(appid, Global.userid().intValue(), null, "调查", advice, null, nowTime, this.type, count, cpic200.getPath()));
			} catch (Exception e) {
				throw new Exceptions("信息保存失败!");
			}
			
			/*判断调查是否完成，并预设审查信息*/
			
				if(applyStateService.isAllSurveyDo(appid, "A")){
					applyStateService.saveAllByManagerId(appid, examineUser.getUserId().intValue(), "B", this.type, count);
					applyStateService.saveAllByManagerId(appid, adviceUser.getUserId().intValue(), "BB", this.type, count);
					_creditApplyEnterprise.setCreditstate(21);
					_creditApplyEnterprise.setIsdone(1);
				}
				
			/*设定利率及相关修改的信息*/
			try {	
				//_creditApplyEnterprise.setApplytime(applytime);
				//_creditApplyEnterprise.setApplytimetype(applytimetype);
				_creditApplyEnterprise.setLoanaccount(loanaccount);
				_creditApplyEnterprise.setApplybaserate(applybaserate);
				_creditApplyEnterprise.setSlidingscale(slidingscale);
				_creditApplyEnterprise.setPerformrates(performrates);
			} catch (Exception e) {
				throw new Exception("利率设定失败,请检查你利率是否合法!");
			}
			
			try {
				this.creditApplyEnterpriseService.save(_creditApplyEnterprise);
				Log.save("插入", "企业调查信息的保存，申请单的号码为：" + _creditApplyEnterprise.getApplyid(), "调查报告的路径为：" + cpic200.getPath());
			} catch (Exception e) {
				throw new Exceptions("在执行过程中出现了错误了!");
			}
		}
		
		MessageJump("信息调查完成", "creditSurveyAction?type=" + this.type);
		return "message";
	}
	
	/**
	 * 显示根据applyid查询信息
	 * */
	public String searchList() throws Exceptions{
		
		//处理applyid
		try{
			this.applyid = Integer.parseInt(this.searchApplyid);
		}catch(Exception e){
			this.applyid = Integer.parseInt(this.searchApplyid.substring(3, this.searchApplyid.length()));
		}
		
		if(this.type == 1){
			this.creditAcceptBeanList = this.creditApplyPersonalService.getAllAcceptionListByApplyIdAndState(this.applyid, "survey");
		}else if(this.type == 2){
			this.creditAcceptBeanList = this.creditApplyEnterpriseService.getAllAcceptionListByApplyIdAndState(this.applyid, "survey");
		}
		return "success";
	}
	
	/**
	 * 显示等待列表信息
	 * */
	public String cdw() throws Exceptions{
		if(this.type == 1){
			this.creditAcceptBeanList = this.creditApplyPersonalService.getAllSurveyList("wait");
		}else if(this.type == 2){
			this.creditAcceptBeanList = this.creditApplyEnterpriseService.getAllSurveyList("wait");
		}
		this.searchwhat = 1;
		return "success";
	}
	
	/**
	 * 显示完成列表信息
	 * */
	public String cdd() throws Exceptions{
		if(this.type == 1){
			this.creditAcceptBeanList = this.creditApplyPersonalService.getAllSurveyList("done");
		}else if(this.type == 2){
			this.creditAcceptBeanList = this.creditApplyEnterpriseService.getAllSurveyList("done");
		}
		this.searchwhat = 2;
		return "success";
	}
	
	/**
	 * 显示上级返回列表信息
	 * */
	public String cdr() throws Exceptions{
		if(this.type == 1){
			this.creditAcceptBeanList = this.creditApplyPersonalService.getAllSurveyList("returnBack");
		}else if(this.type == 2){
			this.creditAcceptBeanList = this.creditApplyEnterpriseService.getAllSurveyList("returnBack");
		}
		this.searchwhat = 3;
		return "success";
	}
	
	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public List<?> getCreditAcceptBeanList() {
		return creditAcceptBeanList;
	}
	public void setCreditAcceptBeanList(List<?> creditAcceptBeanList) {
		this.creditAcceptBeanList = creditAcceptBeanList;
	}
	public CreditCheckBean getCreditCheckBean() {
		return creditCheckBean;
	}
	public void setCreditCheckBean(CreditCheckBean creditCheckBean) {
		this.creditCheckBean = creditCheckBean;
	}
	public List<Integer> getIsAccept() {
		return isAccept;
	}
	public void setIsAccept(List<Integer> isAccept) {
		this.isAccept = isAccept;
	}
	public List<Integer> getAcceptPeople() {
		return acceptPeople;
	}
	public void setAcceptPeople(List<Integer> acceptPeople) {
		this.acceptPeople = acceptPeople;
	}
	
	public ApplyStateService getApplyStateService() {
		return applyStateService;
	}
	public void setApplyStateService(ApplyStateService applyStateService) {
		this.applyStateService = applyStateService;
	}
	public CreditApplyPersonalService getCreditApplyPersonalService() {
		return creditApplyPersonalService;
	}
	public void setCreditApplyPersonalService(
			CreditApplyPersonalService creditApplyPersonalService) {
		this.creditApplyPersonalService = creditApplyPersonalService;
	}
	public CreditApplyEnterpriseService getCreditApplyEnterpriseService() {
		return creditApplyEnterpriseService;
	}
	public void setCreditApplyEnterpriseService(
			CreditApplyEnterpriseService creditApplyEnterpriseService) {
		this.creditApplyEnterpriseService = creditApplyEnterpriseService;
	}

	public List<?> getRecordList() {
		return recordList;
	}

	public void setRecordList(List<?> recordList) {
		this.recordList = recordList;
	}

	public ApplyOpinionService getApplyOpinionService() {
		return applyOpinionService;
	}

	public void setApplyOpinionService(ApplyOpinionService applyOpinionService) {
		this.applyOpinionService = applyOpinionService;
	}

	public int getIsCanChange() {
		return isCanChange;
	}

	public void setIsCanChange(int isCanChange) {
		this.isCanChange = isCanChange;
	}

	public AppRate getAppRate() {
		return appRate;
	}

	public void setAppRate(AppRate appRate) {
		this.appRate = appRate;
	}

	public AppRateService getAppRateService() {
		return appRateService;
	}

	public void setAppRateService(AppRateService appRateService) {
		this.appRateService = appRateService;
	}

	public String getAdvice() {
		return advice;
	}

	public void setAdvice(String advice) {
		this.advice = advice;
	}

	public Double getApplybaserate() {
		return applybaserate;
	}

	public void setApplybaserate(Double applybaserate) {
		this.applybaserate = applybaserate;
	}

	public Double getSlidingscale() {
		return slidingscale;
	}

	public void setSlidingscale(Double slidingscale) {
		this.slidingscale = slidingscale;
	}

	public Double getPerformrates() {
		return performrates;
	}

	public void setPerformrates(Double performrates) {
		this.performrates = performrates;
	}

	public Integer getApplyid() {
		return applyid;
	}

	public void setApplyid(Integer applyid) {
		this.applyid = applyid;
	}

	public Integer getAppid() {
		return appid;
	}

	public void setAppid(Integer appid) {
		this.appid = appid;
	}

	public int getUpOrDown() {
		return upOrDown;
	}

	public void setUpOrDown(int upOrDown) {
		this.upOrDown = upOrDown;
	}

	public ApplyUserService getApplyUserService() {
		return applyUserService;
	}

	public void setApplyUserService(ApplyUserService applyUserService) {
		this.applyUserService = applyUserService;
	}

	public Double getLoanaccount() {
		return loanaccount;
	}

	public void setLoanaccount(Double loanaccount) {
		this.loanaccount = loanaccount;
	}

	public Integer getApplytime() {
		return applytime;
	}

	public void setApplytime(Integer applytime) {
		this.applytime = applytime;
	}

	public String getApplytimetype() {
		return applytimetype;
	}

	public List<AppLoantype> getLoantypeList() {
		return loantypeList;
	}

	public void setLoantypeList(List<AppLoantype> loantypeList) {
		this.loantypeList = loantypeList;
	}

	public AppLoantypeService getAppLoantypeService() {
		return appLoantypeService;
	}

	public void setAppLoantypeService(AppLoantypeService appLoantypeService) {
		this.appLoantypeService = appLoantypeService;
	}


	public List<String> getLomList() {
		return lomList;
	}

	public void setLomList(List<String> lomList) {
		this.lomList = lomList;
	}

	public void setApplytimetype(String applytimetype) {
		this.applytimetype = applytimetype;
	}

	public List<?> getEnssuerList() {
		return enssuerList;
	}

	public void setEnssuerList(List<?> enssuerList) {
		this.enssuerList = enssuerList;
	}

	public List<?> getHypothecateList() {
		return hypothecateList;
	}

	public void setHypothecateList(List<?> hypothecateList) {
		this.hypothecateList = hypothecateList;
	}

	public List<?> getPledgeList() {
		return pledgeList;
	}

	public void setPledgeList(List<?> pledgeList) {
		this.pledgeList = pledgeList;
	}

	public Creditapplyenterprise getCreditapplyenterprise() {
		return creditapplyenterprise;
	}

	public void setCreditapplyenterprise(Creditapplyenterprise creditapplyenterprise) {
		this.creditapplyenterprise = creditapplyenterprise;
	}

	public Creditapplypersonal getCreditApplyPersonal() {
		return creditApplyPersonal;
	}

	public void setCreditApplyPersonal(Creditapplypersonal creditApplyPersonal) {
		this.creditApplyPersonal = creditApplyPersonal;
	}

	public ApplyCustomRelationSearchService getApplyCustomRelationSearchService() {
		return applyCustomRelationSearchService;
	}

	public void setApplyCustomRelationSearchService(
			ApplyCustomRelationSearchService applyCustomRelationSearchService) {
		this.applyCustomRelationSearchService = applyCustomRelationSearchService;
	}

	public EnterpriseInforBean getEnterpriseInforBean() {
		return enterpriseInforBean;
	}

	public void setEnterpriseInforBean(EnterpriseInforBean enterpriseInforBean) {
		this.enterpriseInforBean = enterpriseInforBean;
	}

	public EnterpriseSearchService getEnterpriseSearchService() {
		return enterpriseSearchService;
	}

	public void setEnterpriseSearchService(
			EnterpriseSearchService enterpriseSearchService) {
		this.enterpriseSearchService = enterpriseSearchService;
	}

	public Personalbasic getPerson() {
		return person;
	}

	public void setPerson(Personalbasic person) {
		this.person = person;
	}

	public PersonalSearchService getPersonalSearchService() {
		return personalSearchService;
	}

	public void setPersonalSearchService(PersonalSearchService personalSearchService) {
		this.personalSearchService = personalSearchService;
	}

	public List<?> getDcommonList() {
		return dcommonList;
	}

	public void setDcommonList(List<?> dcommonList) {
		this.dcommonList = dcommonList;
	}

	public DropDownService getDropDownService() {
		return dropDownService;
	}

	public void setDropDownService(DropDownService dropDownService) {
		this.dropDownService = dropDownService;
	}

	public List<?> getCulturaList() {
		return culturaList;
	}

	public void setCulturaList(List<?> culturaList) {
		this.culturaList = culturaList;
	}
	
	
	
	public void fileSave() throws Exceptions, IOException{
		String savedir = "/dataApplySurvey/";
		if(type == 1){
			savedir += "RFG" + appid;
		}else if(type == 2){
			savedir += "RFQ" + appid;
		}else{
			throw new Exceptions("异常！");
		}
		cpic200 = new Companyfile();
		cpic200.setCid(appid);
		cpic200.setPid(Global.userid());
		cpic200.setType(99);
		cpic200.setName(Global.userid() + "对申请单" + appid + "的调查报告");
		
				//修改时原来存在文件则删除
					
				//根据cfile｛i｝ 后的 i   得到 pic{i} 
				
				if(cpic200.getPath() != null && pic200 != null){
					 String realPath = ServletActionContext.getServletContext().getRealPath(savedir);
					 String tp = cpic200.getPath();
					 int tin =tp.lastIndexOf("/");
					 if(tin != -1){
							// 在该实际路径下实例化一个文件  
							 File cf = new File(new File(realPath), tp.substring(tin+1)); 
							 if(cf.exists())
								 FileUtils.forceDelete(cf);
						 }
				}
				if(pic200 != null){
					cpic200.setPath(uploadFile(pic200,pic200FileName, savedir));
					customServiceDo.fileSave(cpic200);
				}
	}
	
	
	
	public String uploadFile(File tpic,String tpicFileName, String savedir){
		//TimeTest tt = new TimeTest();
		/* tomcat中jsp引用图片img的src属性带中文路径无法显示的解决
		 * 在tomcat的server.xml中加入URIEncoding="utf-8"（网页的编码是utf-8）
		<Connector port="8080" connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="utf-8" />
		如果用apache代理tomcat，是通过ajp端口，所以也需要设置：
		<Connector port="6009" protocol="AJP/1.3" redirectPort="8443" URIEncoding="utf-8"/>
		 */
		
		String picname = Global.userid() + tpicFileName;  //实际存储的文件名
		
		//String savedir="/data/"+"RFQ"+(Integer)Sessions.get("applyid"); //文件夹
		
		picUrl=".." + savedir + "/" + picname;        //显示路径
		
        if (tpic == null || tpic.length() > 41943004) {  
            return "error";  
        }  
        //for (String s : str) {  
           // if (pic1fileName.endsWith(s)) {  
                String realPath = ServletActionContext.getServletContext().getRealPath(savedir);
                File saveFile = new File(new File(realPath), picname); // 在该实际路径下实例化一个文件  
                // 判断父目录是否存在  
                if (!saveFile.getParentFile().exists()) {  
                    saveFile.getParentFile().mkdirs();  
                }  
                try {  
                    FileUtils.copyFile(tpic, saveFile); 
                } catch (IOException e) {  
                    return "imageError";  
                }
            //}  
        //}  
       // System.out.println("picUrl = " + picUrl);
		return picUrl;
	}

	public CustomServiceDo getCustomServiceDo() {
		return customServiceDo;
	}

	public void setCustomServiceDo(CustomServiceDo customServiceDo) {
		this.customServiceDo = customServiceDo;
	}

	public String getPicUrl() {
		return picUrl;
	}

	public void setPicUrl(String picUrl) {
		this.picUrl = picUrl;
	}

	public Companyfile getCpic200() {
		return cpic200;
	}

	public void setCpic200(Companyfile cpic200) {
		this.cpic200 = cpic200;
	}

	public File getPic200() {
		return pic200;
	}

	public void setPic200(File pic200) {
		this.pic200 = pic200;
	}

	public String getPic200FileName() {
		return pic200FileName;
	}

	public void setPic200FileName(String pic200FileName) {
		this.pic200FileName = pic200FileName;
	}

	public int getSearchwhat() {
		return searchwhat;
	}

	public void setSearchwhat(int searchwhat) {
		this.searchwhat = searchwhat;
	}

	public String getSearchApplyid() {
		return searchApplyid;
	}

	public void setSearchApplyid(String searchApplyid) {
		this.searchApplyid = searchApplyid;
	}
	

}
